/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FavoriteProductPanel.java
 *
 * Created on Feb 17, 2012, 1:18:04 PM
 */
package dkgg2012group22imat.view;

import dkgg2012group22imat.controller.ProductsPanelController;
import java.awt.Color;
import java.util.List;
import se.chalmers.ait.dat215.project.Product;

/**
 *
 * @author jonas
 */
public class ProductsPanel extends javax.swing.JPanel {

    private ProductsPanelController controller;

    /** Creates new form FavoriteProductPanel */
    @Deprecated
    public ProductsPanel(List<Product> prods, int amount) {
        initComponents();
        controller = new ProductsPanelController(prods, amount, this);
    }
        /** Creates new form FavoriteProductPanel */
    public ProductsPanel(List<Product> prods) {
        initComponents();
        controller = new ProductsPanelController(prods, this);
    }

    public void setList(List<Product> prods) {
        controller.setList(prods);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        navigationPanel = new javax.swing.JPanel();
        forwardButton = new javax.swing.JButton();
        backButton = new javax.swing.JButton();
        pagenationPanel = new javax.swing.JPanel();
        productPanel = new javax.swing.JPanel();

        setName("Form"); // NOI18N
        setOpaque(false);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });
        setLayout(new java.awt.BorderLayout());

        navigationPanel.setName("navigationPanel"); // NOI18N
        navigationPanel.setOpaque(false);
        navigationPanel.setPreferredSize(new java.awt.Dimension(290, 40));
        navigationPanel.setLayout(new java.awt.BorderLayout());

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(dkgg2012group22imat.view.DKGG2012Group22iMatApp.class).getContext().getResourceMap(ProductsPanel.class);
        forwardButton.setFont(resourceMap.getFont("forwardButton.font")); // NOI18N
        forwardButton.setForeground(resourceMap.getColor("forwardButton.foreground")); // NOI18N
        forwardButton.setIcon(resourceMap.getIcon("forwardButton.icon")); // NOI18N
        forwardButton.setText(resourceMap.getString("forwardButton.text")); // NOI18N
        forwardButton.setBorderPainted(false);
        forwardButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        forwardButton.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        forwardButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        forwardButton.setMinimumSize(new java.awt.Dimension(140, 51));
        forwardButton.setName("forwardButton"); // NOI18N
        forwardButton.setPreferredSize(new java.awt.Dimension(140, 51));
        forwardButton.setRolloverIcon(resourceMap.getIcon("forwardButton.rolloverIcon")); // NOI18N
        forwardButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseExited(java.awt.event.MouseEvent evt) {
                forwardButtonMouseExited(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                forwardButtonMouseEntered(evt);
            }
        });
        forwardButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                forwardButtonActionPerformed(evt);
            }
        });
        navigationPanel.add(forwardButton, java.awt.BorderLayout.EAST);

        backButton.setBackground(resourceMap.getColor("backButton.background")); // NOI18N
        backButton.setFont(resourceMap.getFont("backButton.font")); // NOI18N
        backButton.setForeground(resourceMap.getColor("backButton.foreground")); // NOI18N
        backButton.setIcon(resourceMap.getIcon("backButton.icon")); // NOI18N
        backButton.setText(resourceMap.getString("backButton.text")); // NOI18N
        backButton.setBorderPainted(false);
        backButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        backButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        backButton.setMaximumSize(new java.awt.Dimension(140, 51));
        backButton.setMinimumSize(new java.awt.Dimension(140, 51));
        backButton.setName("backButton"); // NOI18N
        backButton.setPreferredSize(new java.awt.Dimension(140, 51));
        backButton.setRolloverIcon(resourceMap.getIcon("backButton.rolloverIcon")); // NOI18N
        backButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseExited(java.awt.event.MouseEvent evt) {
                backButtonMouseExited(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                backButtonMouseEntered(evt);
            }
        });
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });
        navigationPanel.add(backButton, java.awt.BorderLayout.WEST);

        pagenationPanel.setName("pagenationPanel"); // NOI18N
        pagenationPanel.setOpaque(false);
        navigationPanel.add(pagenationPanel, java.awt.BorderLayout.CENTER);

        add(navigationPanel, java.awt.BorderLayout.NORTH);

        productPanel.setBackground(resourceMap.getColor("productPanel.background")); // NOI18N
        productPanel.setName("productPanel"); // NOI18N
        productPanel.setOpaque(false);
        productPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0));
        add(productPanel, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

private void forwardButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_forwardButtonActionPerformed
    controller.viewNextProducts();
}//GEN-LAST:event_forwardButtonActionPerformed

private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
    controller.viewPrevProducts();
}//GEN-LAST:event_backButtonActionPerformed

private void forwardButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_forwardButtonMouseEntered
//    forwardButton.setText("Visa fler varor");
    forwardButton.setForeground(new Color(51,51,51));
}//GEN-LAST:event_forwardButtonMouseEntered

private void forwardButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_forwardButtonMouseExited
//    forwardButton.setText("");
    forwardButton.setForeground(new Color(102,102,102));
}//GEN-LAST:event_forwardButtonMouseExited

private void backButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_backButtonMouseEntered
//    backButton.setText("Tillbaka");
    backButton.setForeground(new Color(51,51,51));
}//GEN-LAST:event_backButtonMouseEntered

private void backButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_backButtonMouseExited
//    backButton.setText("");
    backButton.setForeground(new Color(102,102,102));
}//GEN-LAST:event_backButtonMouseExited

private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
    controller.reSized();
}//GEN-LAST:event_formComponentResized
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton backButton;
    public javax.swing.JButton forwardButton;
    public javax.swing.JPanel navigationPanel;
    public javax.swing.JPanel pagenationPanel;
    public javax.swing.JPanel productPanel;
    // End of variables declaration//GEN-END:variables
}
